package com.citrinus.feedme.places;

import java.text.DecimalFormat;
import java.util.List;

import com.google.android.gms.maps.model.LatLng;

public class Place {

	private String id;
	private String name;
	private String reference;
	private String icon;
	private String vicinity;
	private Geometry geometry;
	private List<String> types;
	private float distanceToUser;

	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getReference() {
		return reference;
	}

	public void setReference(String reference) {
		this.reference = reference;
	}

	public String getIcon() {
		return icon;
	}

	public void setIcon(String icon) {
		this.icon = icon;
	}

	public String getVicinity() {
		return vicinity;
	}

	public void setVicinity(String vicinity) {
		this.vicinity = vicinity;
	}

	public Geometry getGeometry() {
		return geometry;
	}

	public void setGeometry(Geometry geometry) {
		this.geometry = geometry;
	}

	public List<String> getTypes() {
		return types;
	}

	public void setTypes(List<String> types) {
		this.types = types;
	}

	public void setLatLng(double latitude, double longitude) {
		geometry = new Geometry();
		Location location = new Location();
		location.setLat(latitude);
		location.setLng(longitude);
		geometry.setLocation(location);
	}

	public float getDistanceToUserInYards() {
		float toYards = Float.valueOf("1.09361");
		return distanceToUser*toYards;
	}

	public void setDistanceToUser(float distanceToUser) {
		this.distanceToUser = distanceToUser;
	}

	public String getDistanceInYards(){
		float toYards = Float.valueOf("1.09361");
		float yards = distanceToUser*toYards;
		
		DecimalFormat df = new DecimalFormat("#.0");
		return df.format(yards)+" yd";		
	}
	
	@Override
	public String toString() {
		return name + " - " + id + " - " + reference;
	}

	public static class Geometry {
		private Location location;

		public Location getLocation() {
			return location;
		}

		public void setLocation(Location location) {
			this.location = location;
		}

	}

	public static class Location {
		private double lat;
		private double lng;

		public double getLat() {
			return lat;
		}

		public void setLat(double lat) {
			this.lat = lat;
		}

		public double getLng() {
			return lng;
		}

		public void setLng(double lng) {
			this.lng = lng;
		}

		public LatLng getLatLng() {
			return new LatLng(lat, lng);
		}

	}

}